const QQMapWX = require("../../../libs/qqmap-wx-jssdk.min")

Page({
  // 先拿到小区名和楼号
  onLoad ({ point, building }) {
    // 伪造一下房间数据
    this.fake(point, building)
  },
  // 伪造房间号数据 (仅用于学习开发)
  fake (point, building) {
    const rooms = []
    for (let i = 0; i < 9; i++) {
      // 随机楼层
      const floor = Math.floor(Math.random() * 20) + 1
      // 房间号
      const No = Math.floor(Math.random() * 3) + 1
      // 拼接一下房间号
      const room = [floor, 0, No].join('')
      // 如果有重复的房间号,就不添加了
      if (rooms.includes(room)) continue
      // 记录房间号
      rooms.push(room)
    }

    // 数据放到data里用于页面渲染
    this.setData({ rooms, point, building })
  },
  // 跳转到表单页面
  goForm (e) {
    // 获取一下小区名和楼栋号
    const { point, building } = this.data
    wx.navigateTo({
      url: `/house_pkg/pages/form/index?point=${point}&building=${building}&room=${e.mark.room}`
    })
  }
})